﻿Imports System.Data
Partial Class Default2
    Inherits System.Web.UI.Page

    Dim ocnTrabajo As New Negocio.Trabajo
    Dim ocnProfesor As New Negocio.Profesor
    Dim ocnAlumno As New Negocio.Alumno

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            ocnTrabajo.RegistrarTF(Me.TBexpediente.Text, Me.TBtrabajo.Text, Me.TBalumno.Text, Me.TBprofguia.Text, Me.TBprofasesor.Text, CDate(Me.TBfecha.Text), CDate(Me.TBexamen.Text), Me.TBplan.Text)
            Me.GridView1.DataSource = ocnTrabajo.obtenerTrabajoExpediente(Me.TBexpediente.Text)
            Me.GridView1.DataBind()
        Catch ex As Exception
            Session.Add("Error", ex.Message)
            Response.Redirect("ManejarErrores.aspx")
        End Try
    End Sub

    Protected Sub TBprofguia_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles TBprofguia.Init
        Dim ds As New DataSet
        ds = ocnProfesor.obtenerProfesores()
        With Me.TBprofguia
            .DataSource = ds.Tables("Profesores").DefaultView
            .DataTextField = "nombre"
            .DataValueField = "dni"
        End With
        Me.TBprofguia.DataBind()
    End Sub

    Protected Sub TBprofasesor_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles TBprofasesor.Init
        Dim ds As New DataSet
        ds = ocnProfesor.obtenerProfesores()
        With Me.TBprofasesor
            .DataSource = ds.Tables("Profesores").DefaultView
            .DataTextField = "nombre"
            .DataValueField = "dni"
        End With
        Me.TBprofasesor.DataBind()
    End Sub

    Protected Sub TBalumno_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles TBalumno.Init
        Dim ds As New DataSet
        ds = ocnAlumno.obtenerAlumnos()
        With Me.TBalumno
            .DataSource = ds.Tables("Alumnos").DefaultView
            .DataTextField = "nombre"
            .DataValueField = "dni"
        End With
        Me.TBalumno.DataBind()

    End Sub
End Class
